package run.halo.app.controller.front.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.common.R;
import run.halo.app.model.entity.front.Customer;
import run.halo.app.model.vo.front.CustomerVO;
import run.halo.app.service.front.CustomerService;
import java.util.Optional;

/**
 * c端用户Controller
 * @author wupeng
 * @date 2022年10月16日21:51:13
 */
@RestController
@RequestMapping("/api/front/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;


    @GetMapping("/info/{token}")
    public R<CustomerVO> getCustomerInfo(@PathVariable String token){
        Optional<CustomerVO> optionalCustomer = customerService.findByToken(token);
        if(!optionalCustomer.isEmpty()){
            return R.ok(optionalCustomer.get());
        }
        return R.fail("查不到对应登录信息！");
    }
}
